﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI.HtmlControls;

public class ForumCore : System.Web.UI.Page
{
	public ForumCore()
	{
		
	}

    public static List<String> returnCategory() {

        return DB.selectQuery("ForumDB", "select * from category");
     
    }
    public static String returnCategoryOwner(String scelta)
    {

        return DB.selectQuery("ForumDB", "select creator from category where name='"+ scelta + "'")[0];

    }
    public static List<String> returnArgoment(String scelta)
    {
        
        return DB.selectQuery("ForumDB", "select name from Topic where visible = 1 and category='"+ scelta+"'");

    }
    public static List<String> returnArgomentViews(String scelta)
    {

        return DB.selectQuery("ForumDB", "select views from Topic where visible = 1 and category='" + scelta + "'");

    }
    public static List<String> returnArgomentOwner(String scelta)
    {

        return DB.selectQuery("ForumDB", "select creator from Topic where visible = 1 and category='" + scelta + "'");

    }
    public static List<String> returnPost(String scelta)
    {

        return DB.selectQuery("ForumDB", "select content from Post where topic_id= (select id_topic from topic where name ='" + scelta + "')");

    }
    public static List<String> returnPostOwner(String scelta)
    {

        return DB.selectQuery("ForumDB", "select creator from post where topic_id= (select id_topic from topic where name ='"+scelta+"')");

    }
    public static int getNrTopic(String scelta)
    {
        return int.Parse(DB.selectQuery("ForumDB", "select count(*) from topic where category ='"+ scelta + "'")[0]);
    }
    public static int getNrPost(String scelta)
    {
        return int.Parse(DB.selectQuery("ForumDB", "select count(*) from post where topic_id = (select id_topic from topic where name ='"+scelta+"')")[0]);
    }

}